	
-- ***********************************************************************************************
-- GETUPDATECONFLICT Stored Procedures for the list of tables mentioned in the Initialize file
--------------------------------------------------------------------------------------------------

--TABLE NAME: OrderHeader    STORED PROCEDURE NAME: Sales.sync_sp_OrderHeader_GetUpdateConflict

use [SyncSamplesDb_ChangeTracking_Custom]

if object_id(N'Sales.sync_sp_OrderHeader_GetUpdateConflict', 'P') is not null
	drop procedure Sales.sync_sp_OrderHeader_GetUpdateConflict
GO

	create procedure Sales.sync_sp_OrderHeader_GetUpdateConflict(
        @OrderId uniqueidentifier       
        )
as
	SELECT		E.OrderId
				, E.CustomerId
				, E.OrderDate
				, E.OrderStatus
				, CT.SYS_CHANGE_CONTEXT
				, CT.SYS_CHANGE_VERSION 
	FROM		[SyncSamplesDb_ChangeTracking_Custom].[Sales].[OrderHeader] AS E
	JOIN		CHANGETABLE(VERSION [SyncSamplesDb_ChangeTracking_Custom].[Sales].[OrderHeader], ([OrderId]), (@OrderId)) AS CT  
				ON E.OrderId = CT.OrderId

GO

-------------------------------------------END------------------------------------------------------------------
